<script>


    $(function(){
        $("input[name='xiaoqu']").autocomplete({
            delay: 500,
//            source: "availableTags",
            source: function(request, response) {



                $.ajax({
                    url: '/Api/Index/get_xiaoqu_select/name/' +  encodeURIComponent(request.term),
                    dataType: 'json',
                    success: function(json) {

                        if(json!=null){
                            response($.map(json, function(item) {
                                return {
                                    label: item.name,
                                    value: item.id
                                }
                            }));
                        }else {
                            $(".ui-widget-content").hide();
                        }

                    }
                });
            },
            select: function(event, ui) {


                $("input[name='xiaoqu']").val(ui.item.label);

                target="/Api/Index/get_shop_select/xiaoqu/"+ui.item.value;
//

                $.get(target).success(function(data){


                    if(data){
                        $("input[name='shop_id']").val(data.id);
                        $("#shop_id").html(data.name);
                    }




                });


                return false;
            },
            focus: function(event, ui) {
                return false;
            }
        });
    })
</script>